package com.hdu.other.tanxin;


public class lc45 {
    class Solution {
        public int jump(int[] nums)
        {
            int ans = 0;
            int cur = 0;
            int next = 0;
            for (int i = 0; i < nums.length; i++)
            {
                if (cur >= nums.length - 1)
                {
                    return ans;
                }
                next = Math.max(next, i + nums[i]);
                if (cur == i)
                {
                    ans++;
                    cur = next;
                    if (cur >= nums.length - 1)
                    {
                        return ans;
                    }
                }
            }
            return ans;
        }
    }
}
